{template 'web/_header'}
{template 'web/member/tabs'}

{if $operation=='display'}
<div class="panel panel-info">
    <div class="panel-heading">筛选</div>
    <div class="panel-body">
        <form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="ewei_shop" />
            <input type="hidden" name="do" value="member" />
                 <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">ID</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <input type="text" class="form-control"  name="mid" value="{$_GPC['mid']}"/> 
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">UID</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <input type="text" class="form-control"  name="uid" value="{$_GPC['uid']}"/> 
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">会员信息</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <input type="text" class="form-control"  name="realname" value="{$_GPC['realname']}" placeholder="可搜索昵称/姓名/手机号"/> 
                </div>
            </div>
               <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">是否关注</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <select name='followed' class='form-control'>
                        <option value=''></option>
                        <option value='0' {if $_GPC['followed']=='0'}selected{/if}>未关注</option>
                        <option value='1' {if $_GPC['followed']=='1'}selected{/if}>已关注</option>
                        <option value='2' {if $_GPC['followed']=='2'}selected{/if}>取消关注</option>
                    </select>
                </div>
            </div>
             <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">会员等级</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                       <select name='level' class='form-control'>
                        <option value=''></option>
                        {loop $levels $level}
                        <option value='{$level['id']}' {if $_GPC['level']==$level['id']}selected{/if}>{$level['levelname']}</option>
                        {/loop}
                    </select>
                </div>
            </div>
             <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">会员分组</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                       <select name='groupid' class='form-control'>
                        <option value=''></option>
                        {loop $groups $group}
                        <option value='{$group['id']}' {if $_GPC['groupid']==$group['id']}selected{/if}>{$group['groupname']}</option>
                        {/loop}
                    </select>
                </div>
        
            </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">注册时间</label>
                      <div class="col-sm-2">
                            <label class='radio-inline'>
                                <input type='radio' value='0' name='searchtime' {if $_GPC['searchtime']=='0'}checked{/if}>不搜索
                            </label>
                             <label class='radio-inline'>
                                <input type='radio' value='1' name='searchtime' {if $_GPC['searchtime']=='1'}checked{/if}>搜索
                            </label>
                     </div>
                    <div class="col-sm-7 col-lg-9 col-xs-12">
                        {php echo tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d H:i', $starttime),'endtime'=>date('Y-m-d  H:i', $endtime)),true);}
                    </div>
                         
                </div>
              <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
                    <div class="col-sm-7 col-lg-9 col-xs-12">
                       <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                       <input type="hidden" name="token" value="{$_W['token']}" />
                       {ifp 'member.member.export'}
                        <button type="submit" name="export" value="1" class="btn btn-primary">导出 Excel</button>
                        {/if}
                        <button type="submit" name="export_credit" value="1" class="btn btn-primary">导出余额数据</button>
                    </div>
                         
                </div>
          
            
            <div class="form-group">
            </div>
        </form>
    </div>
</div>
<div class="panel panel-default">
    <div class="panel-heading">总数：{$total}</div>
    <div class="panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
                <tr>
                    <th style='width:80px;'>会员ID</th>
                    <th style='width:80px;'>会员UID</th>
                    <th style='width:120px;'>粉丝</th>
                    <th style='width:80px;'>会员姓名</th>
                    <th style='width:120px;'>手机号码</th>
                    <th style='width:120px;'>会员等级/分组</th>
                    <th style='width:130px;'>注册时间</th>
                    <th style='width:80px;'>积分</th>
                    <th style='width:80px;'>余额</th>
                    <th style='width:80px;'>冻结余额</th>
                    <th style='width:80px;'>成交订单</th>
                    <th style='width:80px;'>成交金额</th>
                    <th style='width:100px'>关注</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $row}
                <tr>
                    <td>{$row['id']}</td>
                    <td>{$row['uid']}</td>
                    <td><img src='{$row['avatar']}' style='width:30px;height:30px;padding1px;border:1px solid #ccc' /> {$row['nickname']}
                    </td>
                    <td>{$row['realname']}</td>
                    <td>{$row['mobile']}</td>
                    <td>{if empty($row['levelname'])}普通会员{else}{$row['levelname']}{/if}
                        <br/>{if empty($row['groupname'])}无分组{else}{$row['groupname']}{/if}</td>
      
                    <td>{php echo date('Y-m-d H:i',$row['createtime'])}</td>
                    <td>{$row['credit1']}</td>
                    <td>{$row['credit2']}</td>
                    <td>{$row['dongjie']}</td>
                    <td>{$row['ordercount']}</td>
                    <td>{php echo floatval($row['ordermoney'])}</td>
                    <td>  {if empty($row['followed'])}
                        {if empty($row['uid'])}
                        <label class='label label-default'>未关注</label>
                        {else}
                        <label class='label label-warning'>取消关注</label>
                        {/if}
                        {else}
                    <label class='label label-success'>已关注</label>    
                    {/if}</td>
                    <td>
                        
                        {ifp 'member.member.view|member.member.edit'}<a class='btn btn-default' href="{php echo $this->createWebUrl('member',array('op'=>'detail','id' => $row['id']));}" title="会员详情"><i class='fa fa-edit'></i></a>{/if}
                        {ifp 'order'}<a class='btn btn-default' href="{php echo $this->createWebUrl('order', array('op' => 'display','openid'=>$row['openid']))}" title='会员订单'><i class='fa fa-list'></i></a>{/if}
                        {ifp 'finance.recharge.credit1'}<a class='btn btn-default' href="{php echo $this->createWebUrl('finance/recharge', array('op'=>'credit1','id'=>$row['id']))}" title='充值积分'><i class='fa fa-credit-card'></i></a>{/if}
                        {ifp 'finance.recharge.credit2'}<a class='btn btn-default' href="{php echo $this->createWebUrl('finance/recharge', array('op'=>'credit2','id'=>$row['id']))}" title='充值余额'><i class='fa fa-money'></i></a>{/if}
                        <a class='btn btn-default' href="{php echo $this->createWebUrl('finance/recharge', array('op'=>'gift','id'=>$row['id']))}" title='充值礼品券'><i class='fa fa-gift'></i></a>
                        <a class='btn btn-default' href="{php echo $this->createWebUrl('finance/recharge', array('op'=>'gold','id'=>$row['id']))}" title='充值金币券'><i class='fa fa-money'></i></a>
                        {ifp 'member.member.delete'}<a class='btn btn-default' href="{php echo $this->createWebUrl('member',array('op'=>'delete','id' => $row['id']));}" title='删除会员' onclick="return confirm('确定要删除该会员吗？');"><i class='fa fa-remove'></i></a>{/if}
                    </td>
                </tr>
                {/loop}
            </tbody>
        </table>
           {$pager}
    </div>
</div>

{else if $operation=='detail'}

<form {if 'member.member.edit'}action="" method='post'{/if} class='form-horizontal'>
    <input type="hidden" name="id" value="{$member['id']}">
    <input type="hidden" name="op" value="detail">
    <input type="hidden" name="c" value="site" />
    <input type="hidden" name="a" value="entry" />
    <input type="hidden" name="m" value="ewei_shop" />
    <input type="hidden" name="do" value="member" />
    <div class='panel panel-default'>
        <div class='panel-heading'>
            会员详细信息
        </div>
        <div class='panel-body'>
             <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">粉丝</label>
                <div class="col-sm-9 col-xs-12">
                    <img src='{$member['avatar']}' style='width:100px;height:100px;padding:1px;border:1px solid #ccc' />
                         {$member['nickname']}
                </div>
            </div>
               <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">OPENID</label>
                <div class="col-sm-9 col-xs-12">
                    <div class="form-control-static">{$member['openid']}</div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">会员等级</label>
                <div class="col-sm-9 col-xs-12">
                    {ifp 'member.member.edit'}
                      <select name='data[level]' class='form-control'>
                        <option value=''>普通会员</option>
                        {loop $levels $level}
                        <option value='{$level['id']}' {if $member['level']==$level['id']}selected{/if}>{$level['levelname']}</option>
                        {/loop}
                    </select>
                    {else}
                    <div class='form-control-static'>
                        {if empty($member['level'])}
                        普通会员
                        {else}
                        {php echo pdo_fetchcolumn('select levelname from '.tablename('ewei_shop_member_level').' where id=:id limit 1',array(':id'=>$member['level']))}
                        {/if}
                    </div>
                    {/if}
                </div>
            </div>
              <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">会员分组</label>
                <div class="col-sm-9 col-xs-12">
                       {ifp 'member.member.edit'}
                      <select name='data[groupid]' class='form-control'>
                        <option value=''>无分组</option>
                        {loop $groups $group}
                        <option value='{$group['id']}' {if $member['groupid']==$group['id']}selected{/if}>{$group['groupname']}</option>
                        {/loop}
                    </select>
                          {else}
                    <div class='form-control-static'>
                        {if empty($member['groupid'])}
                        无分组
                        {else}
                        {php echo pdo_fetchcolumn('select groupname from '.tablename('ewei_shop_member_group').' where id=:id limit 1',array(':id'=>$member['groupid']))}
                        {/if}
                    </div>
                    {/if}
                </div>
            </div>
             
        
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">真实姓名</label>
                <div class="col-sm-9 col-xs-12">
                      {ifp 'member.member.edit'}
                    <input type="text" name="data[realname]" class="form-control" value="{$member['realname']}"  />
                    {else}
                    <div class='form-control-static'>{$member['realname']}</div>
                    {/if}
                </div>
            </div>

            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">手机号码</label>
                <div class="col-sm-9 col-xs-12">
                        {ifp 'member.member.edit'}
                    <input type="text" name="data[mobile]" class="form-control" value="{$member['mobile']}"  />
                      {else}
                    <div class='form-control-static'>{$member['mobile']}</div>
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">微信号</label>
                <div class="col-sm-9 col-xs-12">
                    {ifp 'member.member.edit'}
                          <input type="text" name="data[weixin]" class="form-control" value="{$member['weixin']}"  />
                      {else}
                         <div class='form-control-static'>{$member['weixin']}</div>
                    {/if}
                </div>
            </div>
	         <div class="form-group">
			    <label class="col-xs-12 col-sm-3 col-md-2 control-label">冻结功能</label>
			    <div class="col-sm-9 col-xs-12" >
			        <label for="dongji" class="checkbox-inline">
			            <input type="checkbox" name="data[dongji]" value="1" id="dongji" {if $member['dongji'] == 1}checked="true"{/if} /> 积分
			        </label>
			        <label for="dongyu" class="checkbox-inline">
			            <input type="checkbox" name="data[dongyu]" value="1" id="dongyu" {if $member['dongyu'] == 1}checked="true"{/if} /> 余额
			        </label>
			        <label for="dongquan" class="checkbox-inline">
			            <input type="checkbox" name="data[dongquan]" value="1" id="dongquan" {if $member['dongquan'] == 1}checked="true"{/if} /> 优惠券
			        </label>
			        <label for="dongfan" class="checkbox-inline">
			            <input type="checkbox" name="data[dongfan]" value="1" id="dongfan" {if $member['dongfan'] == 1}checked="true"{/if} /> 返利
			        </label>
			    </div>
			</div>
             <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">成交订单数</label>
                <div class="col-sm-9 col-xs-12">
                    <div class='form-control-static'>{$member['ordercount']}</div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">余额</label>
                <div class="col-sm-9 col-xs-12">
                    <div class='form-control-static'>{$member['credit2']} 元</div>
                </div>
            </div>
               <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">成交金额</label>
                <div class="col-sm-9 col-xs-12">
                    <div class='form-control-static'>{$member['ordermoney']} 元</div>
                </div>
            </div>
               <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">注册时间</label>
                <div class="col-sm-9 col-xs-12">
                    <div class='form-control-static'>{php echo date('Y-m-d H:i:s', $member['createtime']);}</div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">关注状态</label>
                <div class="col-sm-9 col-xs-12">
                    <div class='form-control-static'>
                        {php $followed = m('user')->followed($member['openid'])}
                         {if !$followed}
                            {if empty($member['uid'])}
                            <label class='label label-default'>未关注</label>
                            {else}
                            <label class='label label-warning'>取消关注</label>
                            {/if}
                            {else}
                        <label class='label label-success'>已关注</label>    
                        {/if}
                        
                    </div>
                </div>
            </div>
            
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">备注</label>
                <div class="col-sm-9 col-xs-12">
                      {ifp 'member.member.edit'}
                    <textarea name="content" class='form-control'>{$member['content']}</textarea>
                      {else}
                         <div class='form-control-static'>{$member['content']}</div>
                    {/if}
                </div>
            </div>
              <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                <div class="col-sm-9 col-xs-12">
                    {ifp 'member.member.edit'}
                  <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
	<input type="hidden" name="token" value="{$_W['token']}" />
                  {/if}
                <input type="button" class="btn btn-default" name="submit" onclick="history.go(-1)" value="返回列表" {ifp 'member.member.edit'}style='margin-left:10px;'{/if} />
                </div>
            </div>
            
            
        </div>
     
        
    </div>   
</form>
{/if}
{template 'web/_footer'}